package Operation;

import book.Book;
import book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-04
 * Time: 22:31
 */
public class AddOperation implements Ioperation{
    @Override
    public void work(Booklist booklist) {
        System.out.println("添加一本书");
        System.out.println("请输入书名");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        System.out.println("请输入作者");
        String author = scanner.nextLine();
        System.out.println("请输入类型");
        String type = scanner.nextLine();
        System.out.println("请输入价格");
        double price = scanner.nextDouble();
        Book book = new Book(name,author,type,price);
        int currentsize = booklist.getUsedsize();
        booklist.setBook(currentsize,book);
        booklist.setUsedsize(currentsize+1);
        System.out.println("添加成功");
    }
}
